package com.dqp.cslggroup.School;

import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.appcompat.widget.Toolbar;
import com.bumptech.glide.Glide;
import com.dqp.cslggroup.R;
import com.dqp.cslggroup.UI.BaseActivity;

import java.util.Objects;


public class Schoolcalendar extends BaseActivity {


    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.school_calendar);
        Toolbar toolbar = findViewById(R.id.include_toolbar);
        toolbar.setTitle("");
        setSupportActionBar(toolbar);
        Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
        initText();
        ImageView xl = findViewById(R.id.xl_img);
        Glide.with(this).load("http://47.96.190.22/schoolPhotos/2020-2021-1.png").into(xl);
        xl.setOnClickListener(v -> {
            Uri uri = Uri.parse("http://wx.cslg.edu.cn/h5/xlcx");
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
        });
    }


    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            finish();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    private void initText() {
        SharedPreferences sp;
        SharedPreferences.Editor editor;
        sp = PreferenceManager.getDefaultSharedPreferences(this);
        editor = sp.edit();
        String xl = sp.getString("xl", "");
        editor.apply();
        TextView title = findViewById(R.id.xl_title_in);
        title.setText(xl);
    }


}